package com.bridge.bridgeproject;

import android.annotation.SuppressLint;
import android.app.Application;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bridge.common.base.BaseAppLication;
import com.bridge.common.base.BaseCommonApp;
import com.bridge.common.http.HttpConfig;
import com.bridge.common.http.HttpManager;
import com.bridge.common.interfaces.Services;
import com.yechaoa.yutils.YUtils;

/**
 * Application
 */
public class BridgeComApp extends BaseAppLication {
    @SuppressLint("NewApi")
    @Override
    public void onCreate() {
        super.onCreate();
        initRouter(this);
        BaseCommonApp.setInstance(this);
        //为方便调试，不让应用自动重启，设置自定义崩溃处理
        Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
//初始化
        YUtils.init(this);
        HttpManager.init(BuildConfig.BASE_URL , HttpConfig.TIMEOUT, Services.class  ,this);
    }

    public static void initRouter(Application application) {
        if (BuildConfig.DEBUG) {
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
        }
        ARouter.init(application);
    }
}
